package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.SecurityQuestion;
import org.deadline.repository.config.SecurityQuestionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class SecurityQuestionServiceImpl implements SecurityQuestionService {

	@Autowired
    SecurityQuestionRepository securityQuestionRepository;

	public long countAllSecurityQuestions() {
        return securityQuestionRepository.count();
    }

	public void deleteSecurityQuestion(SecurityQuestion securityQuestion) {
        securityQuestionRepository.delete(securityQuestion);
    }

	public SecurityQuestion findSecurityQuestion(Long id) {
        return securityQuestionRepository.findOne(id);
    }

	public List<SecurityQuestion> findAllSecurityQuestions() {
        return securityQuestionRepository.findAll();
    }

	public List<SecurityQuestion> findSecurityQuestionEntries(int firstResult, int maxResults) {
        return securityQuestionRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveSecurityQuestion(SecurityQuestion securityQuestion) {
        securityQuestionRepository.save(securityQuestion);
    }

	public SecurityQuestion updateSecurityQuestion(SecurityQuestion securityQuestion) {
        return securityQuestionRepository.save(securityQuestion);
    }
}
